﻿<Window x:Class="Cjc.Chromium3D.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:Cjc.Chromium3D"
	xmlns:cjc="clr-namespace:Cjc.ChromiumBrowser;assembly=Cjc.ChromiumBrowser"
	Name="window" Width="700" Height="700"
    Title="YouCube 3" Background="Black">

	<Window.Resources>

		<MaterialGroup x:Key="aBitShiny">
			<DiffuseMaterial Brush="White" Viewport2DVisual3D.IsVisualHostMaterial="True"/>
			<SpecularMaterial SpecularPower="100" Brush="White"/>
		</MaterialGroup>

		<Style x:Key="showFocus" TargetType="{x:Type cjc:WebBrowser}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type cjc:WebBrowser}">
						<ControlTemplate.Triggers>
							<Trigger Property="IsFocused" Value="True">
								<Trigger.EnterActions>
									<BeginStoryboard>
										<Storyboard>
											<ColorAnimation To="#FF00FF00" Storyboard.TargetName="borderBrush" Storyboard.TargetProperty="Color" Duration="0:0:0.2"/>
										</Storyboard>
									</BeginStoryboard>
								</Trigger.EnterActions>
								<Trigger.ExitActions>
									<BeginStoryboard>
										<Storyboard>
											<ColorAnimation To="#0000FF00" Storyboard.TargetName="borderBrush" Storyboard.TargetProperty="Color" Duration="0:0:0.5"/>
										</Storyboard>
									</BeginStoryboard>
								</Trigger.ExitActions>
							</Trigger>
						</ControlTemplate.Triggers>
						<Border BorderThickness="1">
							<Border.BorderBrush>
								<SolidColorBrush x:Name="borderBrush"/>
							</Border.BorderBrush>
							<ContentPresenter />
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

	</Window.Resources>

	<Grid>

		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition/>
		</Grid.RowDefinitions>

		<Grid Name="mainContent" Grid.Row="0" Grid.RowSpan="2" Background="Transparent">

			<Viewport3D Name="viewport" ClipToBounds="False" RenderOptions.EdgeMode="Aliased">

				<ModelVisual3D>
					<ModelVisual3D.Content>
						<Model3DGroup>
							<!-- Light source. -->
							<AmbientLight Color="#606060" />
							<DirectionalLight x:Name="light" Color="#A0A0A0" Direction="0,0,-1"/>
						</Model3DGroup>
					</ModelVisual3D.Content>
				</ModelVisual3D>

				<!-- Camera. -->
				<Viewport3D.Camera>
					<PerspectiveCamera x:Name="camera"
									   Position="0 0 1.5"
									   LookDirection="0 0 -1"
									   UpDirection="0 1 0"
									   FieldOfView="60"
									   NearPlaneDistance="0" />
				</Viewport3D.Camera>

			</Viewport3D>

			<Border Background="#C0F0F0FF" CornerRadius="10,0,0,0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Padding="10">
				<StackPanel>
					<CheckBox Cursor="Hand" IsChecked="{Binding EnableAntiAliasing, Mode=TwoWay, ElementName=window}" HorizontalAlignment="Right">Edge anti-aliasing</CheckBox>
					<ToggleButton Name="allowRotate" Padding="10" FontSize="18" Margin="0,5,0,0"
						  HorizontalAlignment="Right" VerticalAlignment="Bottom" Cursor="Hand"
						  Click="ToggleRotate">Click to rotate or zoom</ToggleButton>
				</StackPanel>
			</Border>

<!--			<TextBlock Name="debug" Foreground="Yellow" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>-->
		</Grid>

		<Border Grid.Row="0" Padding="10" Background="#30000000" CornerRadius="10" Opacity="0.5">
			<Border.Resources>
				<Storyboard x:Key="fadeIn">
					<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.25"/>
				</Storyboard>
				<Storyboard x:Key="fadeOut">
					<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:0.5"/>
				</Storyboard>
			</Border.Resources>
			<Border.Triggers>
				<EventTrigger RoutedEvent="UIElement.MouseEnter">
					<BeginStoryboard Storyboard="{StaticResource fadeIn}"/>
				</EventTrigger>
				<EventTrigger RoutedEvent="UIElement.MouseLeave">
					<BeginStoryboard Storyboard="{StaticResource fadeOut}"/>
				</EventTrigger>
			</Border.Triggers>
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition/>
					<ColumnDefinition Width="Auto"/>
				</Grid.ColumnDefinitions>
				<Label Grid.Column="0" Foreground="White">Address</Label>
				<Grid Grid.Column="1">
					<Rectangle>
						<Rectangle.Fill>
							<DrawingBrush>
								<DrawingBrush.Drawing>
									<DrawingGroup>
										<GeometryDrawing Brush="White">
											<GeometryDrawing.Geometry>
												<RectangleGeometry Rect="0,0,1,1"/>
											</GeometryDrawing.Geometry>
										</GeometryDrawing>
										<GeometryDrawing>
											<GeometryDrawing.Brush>
												<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
													<GradientStop Offset="0" Color="#80FF80"/>
													<GradientStop Offset="0.3" Color="#E0FFE0"/>
													<GradientStop Offset="1" Color="#80FF80"/>
												</LinearGradientBrush>
											</GeometryDrawing.Brush>
											<GeometryDrawing.Geometry>
												<RectangleGeometry Rect="{Binding SelectedBrowser.ProgressRect, ElementName=window}"/>
											</GeometryDrawing.Geometry>
										</GeometryDrawing>
									</DrawingGroup>
								</DrawingBrush.Drawing>
							</DrawingBrush>
						</Rectangle.Fill>
					</Rectangle>
					<TextBox Name="url" Text="{Binding SelectedBrowser.Source, ElementName=window}" Background="Transparent"/>
				</Grid>
				<Button Grid.Column="2" Margin="5,0,0,0" Click="Button_Click" IsDefault="True">Go</Button>
			</Grid>
		</Border>

	</Grid>
</Window>
